layout.tsx 609 B

123456789101112131415161718192021
  1. import { ReactElement } from "react";
  2. import { redirect } from "next/navigation";
  3. import { getServerUrl } from "@/shared/lib/server-url";
  4. import { paths } from "@/shared/constants/paths";
  5. import { serverRequiredUser } from "@/entities/user/model/get-server-session-user";
  6. interface RootLayoutProps {
  7. params: Promise<{ locale: string }>;
  8. children: ReactElement;
  9. }
  10. export default async function RootLayout({ children }: RootLayoutProps) {
  11. const auth = await serverRequiredUser();
  12. if (auth.emailVerified) {
  13. redirect(`${getServerUrl()}/${paths.dashboard}`);
  14. }
  15. return <div>{children}</div>;
  16. }